﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Basic Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234237

namespace QuizHackathon
{
    /// <summary>
    /// A basic page that provides characteristics common to most applications.
    /// </summary>
    public sealed partial class MathHard : QuizHackathon.Common.LayoutAwarePage
    {

        Random rand = new Random();
        int number1, number2;
        int result;
        public MathHard()
        {
            this.InitializeComponent();
        }

        public int getRandomNumber()
        {
            int temp = rand.Next(1, 9);
            return temp;
        }


        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }
        
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            number1 = getRandomNumber();
            number2 = getRandomNumber();
            int opr = rand.Next(0, 1);
            if (opr == 1)
            { 
                result = number1 * number2;
                QuestionTxt.Text = number1.ToString() + "*" + number2.ToString();
            }
            else
            {
                result = number1 / number2;
                QuestionTxt.Text = number1.ToString() + "/" + number2.ToString();
            }

        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            if (ResultBox.Text == result.ToString())
            {
                Displaytxt.Text = "success";
            }
            else
            {
                Displaytxt.Text = "You fail";
            }
        }
    }
}
